export default {
  bind(el, binding) {
    function handler(e) {
      // ivu-input ivu-input-default 点击搜索框不关闭；link router-link-exact-active router-link-active：点击跳转link关闭
      if ((el.contains(e.target) || e.target.className === 'ivu-input ivu-input-default') && e.target.className !== 'link router-link-exact-active router-link-active') {
        return false
      }
      if (binding.expression) {
        binding.value(e)
      }
    }
    el._zClickOutside = handler
    document.addEventListener('click', handler)
  },
  unbind(el) {
    // 解除事件监听
    document.removeEventListener('click', el._zClickOutside)
    delete el._zClickOutside
  }
}
